//
//  CheckNetwork.m
//  eBook
//
//  Created by zhy on 13-1-16.
//  Copyright (c) 2013年 zhan. All rights reserved.
//

#import "CheckNetwork.h"
#import "Reachability.h"

@implementation CheckNetwork

+(int) check{
    int result;
    Reachability *r = [Reachability reachabilityWithHostName:@"www.apple.com"];
    switch ([r currentReachabilityStatus]) {
        case NotReachable:
            // 没有网络连接
        {
            result = 0;
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示"
                                                            message:@"检测无网络\n请检查网络连接"
                                                           delegate:nil
                                                  cancelButtonTitle:@"知道了"
                                                  otherButtonTitles: nil];
            [alert show];
            break;
        }
        case ReachableViaWWAN:
            // 使用3G网络
        {
            result = 1;
            break;
        }
        case ReachableViaWiFi:
            // 使用WiFi网络
        {
            result = 2;
            break;
        }
    }
    return result;
}
@end
